package cn.hd.commonService.enums;

import cn.hd.commonService.vo.ServerEnumVo;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
public enum ServerEnum {
    USER_SERVER("userService","用户服务","cn.hd.userService"),
    AUTHOR_SERVER("authorService","认证服务","cn.hd.authorService");


    private String serverName;//服务名称
    private String serverDesc;//服务描述
    private String packagePath;//服务的包路径
    ServerEnum( String serverName, String serverDesc, String packagePath) {
        this.serverName = serverName;
        this.serverDesc = serverDesc;
        this.packagePath = packagePath;
    }
    public static ServerEnum getByServerName(String serverName){
        for (ServerEnum serverEnum : ServerEnum.values()) {
            if (serverEnum.getServerName().equals(serverName)){
                return serverEnum;
            }
        }
        return null;
    }

    public static List<ServerEnumVo> getList(){
       List<ServerEnum> serverEnumList =  new ArrayList<>();
       serverEnumList.add(USER_SERVER);
       serverEnumList.add(AUTHOR_SERVER);
       List<ServerEnumVo> functionList = new ArrayList<>();
        for (ServerEnum serverEnum : serverEnumList) {
            ServerEnumVo serverEnumVo = new ServerEnumVo(serverEnum.getServerName(), serverEnum.getServerDesc(), serverEnum.getPackagePath());
            functionList.add(serverEnumVo);
        }
       return functionList;
    }

}
